import { IsNotEmpty, Length, IsArray, ValidateIf } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class PostDto {
  @ApiProperty({ description: '标题' })
  @IsNotEmpty({ message: '标题不能为空' })
  @Length(5, 30, { message: '标题长度为5 ~ 30位字符' })
  title: string;

  @ApiProperty({ description: '内容/视频简介' })
  @ValidateIf(o => o.postType == 1)
  @IsNotEmpty()
  content: string;

  @ApiProperty({ description: '帖子类型1-文章 2-视频' })
  @IsNotEmpty({ message: '帖子类型不能为空' })
  postType: number;

  @ApiProperty({ description: '封面数量0-无 1-1张 3-三张' })
  @IsNotEmpty({ message: '封面数量不能为空' })
  coverSize: number;

  @ApiProperty({ description: '封面数量地址' })
  @IsArray()
  coverUrlList: Array<string>;

  @ApiProperty({ description: '视频地址' })
  @ValidateIf(o => o.postType == 2)
  @IsNotEmpty()
  videoUrl: string;

  @ApiProperty({ description: '发布者Id' })
  @IsNotEmpty({ message: '发布者Id不能为空' })
  userId: string;

  @ApiProperty({ description: '定时发布时间' })
  scheduleTime: number;
}
